package com.manor.paradise.util

import android.view.View
import com.facebook.rebound.SimpleSpringListener
import com.facebook.rebound.Spring
import com.facebook.rebound.SpringConfig
import com.facebook.rebound.SpringSystem

class ReboundUtil {

    fun setReboundView(views :View){
        val springSystem = SpringSystem.create()
        val spring = springSystem.createSpring()
        spring.springConfig = SpringConfig.fromOrigamiTensionAndFriction(100.0, 1.0)
        spring.addListener(object : SimpleSpringListener() {

            override fun onSpringUpdate(spring: Spring?) {
                val value = spring!!.currentValue.toFloat()
                val scale = 1.5f - value * 0.5f
                views.setScaleX(scale)
                views.setScaleY(scale)
            }
        })

        spring.endValue = 1.0
    }

}
